﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ExtBusiness;
using ExtBusiness.FlowOperation;
using ExtBusiness.Common;
using ChBusiness.Common;

public partial class OFFICE_Advice : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitInfo();
            BindList();

            if (Request["readFlag"] == "1")
            {
                btnClose.Visible = false;
                btnSave.Width = 0;
                btnSave.Height = 0;
            }
        }
    }

    /// <summary>
    /// 绑定数据
    /// </summary>
    public void BindList()
    {
        DataTable dtSource = null;
        if (ViewState["dtTemp"] == null)
        {
            
            ClsWorkFlow CLWF = new ClsWorkFlow();
            dtSource = CLWF.GetUpdateNotes(Request["iid"], UserId);

            ViewState["dtTemp"] = dtSource;
        }
        else
        {
            dtSource = ViewState["dtTemp"] as DataTable;
        }

        gvSerial.DataSource = dtSource;
        gvSerial.RecordCount = dtSource.Rows.Count;
        gvSerial.PageSize = 18;
        gvSerial.DataBind();
    }

    /// <summary>
    /// 绑定数据
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvSerial_OnLoadData(object sender, EventArgs e)
    {
        BindList();
    }

    /// <summary>
    /// 初始化信息
    /// </summary>
    private void InitInfo()
    {
        OracleSystemOperation osoTemp = new OracleSystemOperation();
        string strWhere = string.Format(" iid='{0}' and userid='{1}'", Request["iid"],UserId);
        txtSqNotes.Text = osoTemp.GetTableFieldValue("XT_UPDATE_INFO", "NOTES", strWhere);
    }

    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        ClsWorkFlow cwfTemp = new ClsWorkFlow();
        cwfTemp.SetTaskUpdateNotes(Request["iid"], UserId, txtSqNotes.Text);

        Common.WindowAppear.WriteAlert(this.Page, "保存成功");
    }
}
